import json
from collections import defaultdict

# 读取原始JSON文件
with open('tryoff_data_simple.json', 'r') as f:
    data = json.load(f)

# 按type分类数据
classified_data = defaultdict(list)

for item in data['data']:
    item_type = item['type']
    classified_data[item_type].append(item)

# 为每个type创建单独的JSON文件
for item_type, items in classified_data.items():
    output_filename = f'tryoff_data_simple_{item_type}.json'
    output_data = {'data': items}
    
    with open(output_filename, 'w') as f:
        json.dump(output_data, f, indent=4)
    
    print(f'已创建文件: {output_filename}，包含 {len(items)} 条数据')

print('分解完成！')